{template header.html}
<script type="text/javascript">
$(function() {
	$(".table_form tr>th").attr("width", 150);
	$(".dr_000 tr").last().addClass("dr_border_none");
	{if $result_error}
	art.dialog.tips('<font color=red>{$result_error.msg}</font>', 3);
	d_tips('{$error.error}', 0);
	{/if}
    //每隔5秒保存表单数据
    {if !$data.id && !$did}
    setInterval("dr_save_add_data()", 5000);
    {/if}
    // 加载草稿
    $("#dr_cgbox").mouseover(function(){
        $(".dr_cgbox").show();
    }).mouseout(function(){
        $(".dr_cgbox").hide();
    });
    // 删除草稿数据
    $(".dr_cgbox_delete").click(function(){
        var did = $(this).attr("did");
        var num = parseInt($("#dr_cg_nums").html());
        $.ajax({
            type: "POST",
            dataType:"json",
            url: memberpath+'index.php?c=api&m=ajax_delete_draft&sid={SITE_ID}&dir={APP_DIR}&did='+did,
            success: function(data) {
                if (data == did) {
                    $("#dr_cgbox_"+did).remove();
                    $("#dr_cg_nums").html(num - 1);
                } else {
                    dr_tips(data);
                }
            },
            error: function(HttpRequest, ajaxOptions, thrownError) { }
        });
    });
    $(".dr_cgbox_select").click(function(){
        var did = $(this).attr("did");
        window.location.href = '{$draft_url}&did='+did;
    });
    // 自动保存草稿
    {if $did}
        setInterval("dr_save_draft_data()", 5000);
    {/if}
});
function show_category_field(catid) {
    {if $category_field_url}
        window.location.href = '{$category_field_url}&catid='+catid;
    {/if}
}
function dr_sync(id, _this) {
	var tid = $("#dr_"+id).val();
	if (tid == 1) {
		$("#dr_"+id).val("0");
		$(_this).attr("src", "{MEMBER_URL}statics/OAuth/"+id+".gif");
	} else {
		$("#dr_"+id).val("1");
		$(_this).attr("src", "{MEMBER_URL}statics/OAuth/"+id+"_on.gif");
	}
}
function dr_select_category() {
	$("#dr_select_category_html > span").hide();
	$("#dr_select_category").show();
}
// 动态保存草稿数据
function dr_save_draft_data() {
    var catid = $('#dr_catid').val();
    $.ajax({
        type: "POST",
        dataType:"json",
        url: memberpath+'index.php?c=api&m=ajax_save_draft&sid={SITE_ID}&dir={APP_DIR}&did={$did}&catid='+catid,
        data: $("#myform").serialize(),
        success: function(data) { },
        error: function(HttpRequest, ajaxOptions, thrownError) { }
    });
}
// 动态保存表单数据
function dr_save_add_data() {
    $.ajax({
        type: "POST",
        dataType:"json",
        url: memberpath+'index.php?c=api&m=ajax_save_add&dir={APP_DIR}',
        data: $("#myform").serialize(),
        success: function(data) { },
        error: function(HttpRequest, ajaxOptions, thrownError) { }
    });
}
</script>
<div class="content clearfix">
	{template navigator.html}
    <div class="article">
		<div class="section_wp drbox" style="width:auto;float:none">
			<div class="section_title">
				<ul class="dr_member_cgbox">
				<li style="float:left;"><a href="javascript:;" class="cur">{$meta_name}</a></li>
				{if $draft_list}
				<li class="cg li" id="dr_cgbox">
					<a class="dr_cgbox_a">草稿（<span id="dr_cg_nums">{count($draft_list)}</span>）</a>
					<fieldset class="dr_cgbox" style="display:none">
						<div class="picList">
							<ul class="cg_items" style="max-height: 400px;overflow-y: auto;">
								{loop $draft_list $t}
								<li id="dr_cgbox_{$t.id}">
									<a href="javascript:;" class="dr_cgbox_delete" did="{$t.id}" title="{lang('del')}"><img align="absmiddle" src="{SITE_URL}dayrui/statics/images/b_drop.png"></a>
									<span>{dr_date($t.inputtime)}</span>
									<a href="javascript:;" class="dr_cgbox_select" did="{$t.id}">{$t.title}</a>
								</li>
								{/loop}
							</ul>
						</div>
					</fieldset>
				</li>
				{/if}
				</ul>
				<div class="cl"></div>
			</div>
			<div class="section_main">
				<form action="" id="myform" name="myform" method="post">
				<input name="action" id="dr_action" type="hidden" value="" />
				<input name="dr_id" id="dr_id" type="hidden" value="{$data.id}" />
				<input name="dr_module" id="dr_module" type="hidden" value="{APP_DIR}" />
				<fieldset>
				<legend>{lang('mod-600')}</legend>
				<table width="100%" class="table_form dr_000">
					{if $isselect}
					<tr>
						<th width="160"><font color="red">*</font>&nbsp;{lang('cat-00')}： </th>
						<td>{$select}</td>
					</tr>
					{else}
					{if !$isedit}
					<tr>
						<th width="160"><font color="red">*</font>&nbsp;{lang('cat-00')}： </th>
						<td id="dr_select_category_html">
						<span>{dr_catpos($catid, '&nbsp;&nbsp;>&nbsp;&nbsp;', FALSE)}&nbsp;&nbsp;</span>
						{if !$data.id}
						<a href="index.php?s={APP_DIR}&c=home&m=add">[重新选择]</a>
						{else}
						<span><a href="javascript:dr_select_category();">[重新选择]</a></span>
						<span id="dr_select_category" style="display:none">{$select}</span>
						{/if}
						</td>
					</tr>
					{else}
					<tr>
						<th width="160"><font color="red">*</font>&nbsp;{lang('cat-00')}： </th>
						<td>{dr_catpos($catid, '&nbsp;&nbsp;>&nbsp;&nbsp;', FALSE)}</td>
					</tr>
					{/if}
					{/if}
					{$myfield}
					<tr>
						<th style="border-bottom:none" width="160">&nbsp;</th>
						<td style="border-bottom:none;padding-top: 20px;">
							<div class="mbutton">
								<button value="" onclick="$('#dr_action').val('draft')" type="submit" class="cgbox_bt">草稿</button>
								<button value="" type="submit" class="{if $verify}next_bt{else}submit_bt{/if}">提交</button>
								{if !$data.id && $ci->get_cache('module-'.SITE_ID.'-'.APP_DIR, 'setting', 'syn2')}
								<label>将它同步至微博：</label>
								<img src="{MEMBER_URL}statics/OAuth/qq_share.gif" onclick="{if $member.oauth.qq}dr_sync('qq_share',this){else}dr_confirm_url('您还没有绑定QQ账号呢，现在就去绑定吗？离开页面内容会消失', '{dr_member_url('account/oauth')}'){/if}" align="absmiddle" style="cursor:pointer" />
								<input name="qq_share" id="dr_qq_share" type="hidden" value="0" />
								&nbsp;
								<img src="{MEMBER_URL}statics/OAuth/sina_share.gif" onclick="{if $member.oauth.sina}dr_sync('sina_share',this){else}dr_confirm_url('您还没有绑定新浪账号呢，现在就去绑定吗？离开页面内容会消失', '{dr_member_url('account/oauth')}'){/if}" align="absmiddle" style="cursor:pointer" />
								<input name="sina_share" id="dr_sina_share" type="hidden" value="0" />
								{/if}
							</div>
						</td>
					</tr>
					</table>
				</form>
			</div>
		</div>
    </div>
</div>
{template footer.html}